require 'action_view/helpers/prototype_helper'
require File.dirname(__FILE__) + '/ujs_helper'
require File.dirname(__FILE__) + '/url_helper'


module SimpleUjs
  module Helpers
    module PrototypeHelper
      include ActionView::Helpers::JavascriptHelper
      include ActionView::Helpers::PrototypeHelper

      include SimpleUjs::Helpers::UjsHelper
      
      alias_method :link_to_remote_without_ujs, :link_to_remote
      def link_to_remote(name, options = {}, html_options = {})
        return link_to_remote_without_ujs(name, options, html_options) unless should_use_ujs?
        html_options["onclick"] = remote_function(options)#.gsub(/this\./, 'Event.element(e).')
        link_to(name, options[:url], html_options)
      end

    end
  end
end
